home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Database Designers / Rational Rose 2000 / Rational Setup.EXE / common / lib / Win32 / Console.pm < prev    next >
Encoding:
Perl POD Document  |  1998-11-15  |  19.5 KB  |  687 lines

  1. package Win32::Console;
  2. #######################################################################
  3. #
  4. # Win32::Console - Perl Module for Windows Clipboard Interaction
  5. # ^^^^^^^^^^^^^^
  6. # Version: 0.03 (07 Apr 1997)
  7. #
  8. #######################################################################
  9.  
  10. require Exporter;       # to export the constants to the main:: space
  11. require DynaLoader;     # to dynuhlode the module.
  12.  
  13. @ISA= qw( Exporter DynaLoader );
  14. @EXPORT = qw(
  15.     BACKGROUND_BLUE
  16.     BACKGROUND_GREEN
  17.     BACKGROUND_INTENSITY
  18.     BACKGROUND_RED
  19.     CAPSLOCK_ON
  20.     CONSOLE_TEXTMODE_BUFFER
  21.     CTRL_BREAK_EVENT    
  22.     CTRL_C_EVENT
  23.     ENABLE_ECHO_INPUT
  24.     ENABLE_LINE_INPUT
  25.     ENABLE_MOUSE_INPUT
  26.     ENABLE_PROCESSED_INPUT
  27.     ENABLE_PROCESSED_OUTPUT
  28.     ENABLE_WINDOW_INPUT
  29.     ENABLE_WRAP_AT_EOL_OUTPUT
  30.     ENHANCED_KEY
  31.     FILE_SHARE_READ
  32.     FILE_SHARE_WRITE
  33.     FOREGROUND_BLUE
  34.     FOREGROUND_GREEN
  35.     FOREGROUND_INTENSITY
  36.     FOREGROUND_RED
  37.     LEFT_ALT_PRESSED
  38.     LEFT_CTRL_PRESSED
  39.     NUMLOCK_ON
  40.     GENERIC_READ
  41.     GENERIC_WRITE
  42.     RIGHT_ALT_PRESSED
  43.     RIGHT_CTRL_PRESSED
  44.     SCROLLLOCK_ON
  45.     SHIFT_PRESSED
  46.     STD_INPUT_HANDLE
  47.     STD_OUTPUT_HANDLE
  48.     STD_ERROR_HANDLE
  49. );
  50.  
  51.  
  52. #######################################################################
  53. # This AUTOLOAD is used to 'autoload' constants from the constant()
  54. # XS function.  If a constant is not found then control is passed
  55. # to the AUTOLOAD in AutoLoader.
  56. #
  57.  
  58. sub AUTOLOAD {
  59.     my($constname);
  60.     ($constname = $AUTOLOAD) =~ s/.*:://;
  61.     #reset $! to zero to reset any current errors.
  62.     $!=0;
  63.     my $val = constant($constname, @_ ? $_[0] : 0);
  64.     if ($! != 0) {
  65. #    if ($! =~ /Invalid/) {
  66. #        $AutoLoader::AUTOLOAD = $AUTOLOAD;
  67. #        goto &AutoLoader::AUTOLOAD;
  68. #    } else {
  69.         ($pack, $file, $line) = caller; undef $pack;
  70.         die "Symbol Win32::Console::$constname not defined, used at $file line $line.";
  71. #    }
  72.     }
  73.     eval "sub $AUTOLOAD { $val }";
  74.     goto &$AUTOLOAD;
  75. }
  76.  
  77.  
  78. #######################################################################
  79. # STATIC OBJECT PROPERTIES
  80. #
  81. $VERSION = "0.03";
  82.  
  83. # %HandlerRoutineStack = ();
  84. # $HandlerRoutineRegistered = 0;
  85.  
  86. #######################################################################
  87. # PUBLIC METHODS
  88. #
  89.  
  90. #======== (MAIN CONSTRUCTOR)
  91. sub new {
  92. #========
  93.     my($class, $param1, $param2) = @_;
  94.  
  95.     my $self = {};
  96.  
  97.     if(defined($param1) 
  98.     and ($param1 == constant("STD_INPUT_HANDLE",  0)
  99.     or   $param1 == constant("STD_OUTPUT_HANDLE", 0)
  100.     or   $param1 == constant("STD_ERROR_HANDLE",  0))) {
  101.  
  102.         $self->{'handle'} = _GetStdHandle($param1);
  103.  
  104.     } else {
  105.  
  106.         $param1 = constant("GENERIC_READ", 0)    | constant("GENERIC_WRITE", 0) unless $param1;
  107.         $param2 = constant("FILE_SHARE_READ", 0) | constant("FILE_SHARE_WRITE", 0) unless $param2;
  108.         $self->{'handle'} = _CreateConsoleScreenBuffer($param1, $param2, 
  109.                                                        constant("CONSOLE_TEXTMODE_BUFFER", 0));
  110.     }
  111.     bless $self, $class;
  112.     return $self;
  113. }
  114.  
  115.  
  116. #============
  117. sub Display {
  118. #============
  119.     my($self)=@_;
  120.     return undef unless ref($self);
  121.  
  122.     return _SetConsoleActiveScreenBuffer($self->{'handle'});
  123. }
  124.  
  125. #===========
  126. sub Select {
  127. #===========
  128.     ($self, $type) = @_;
  129.     return undef unless ref($self);
  130.  
  131.     return _SetStdHandle($type, $self->{'handle'});
  132. }
  133.  
  134.  
  135. #==========
  136. sub Title {
  137. #==========
  138.     my($self, $title) = @_;
  139.  
  140.     $title = $self unless ref($self);
  141.  
  142.     if(defined($title)) {
  143.       return _SetConsoleTitle($title);
  144.     } else {
  145.       return _GetConsoleTitle();
  146.     }
  147. }
  148.  
  149. #==============
  150. sub WriteChar {
  151. #==============
  152.     my($self, $text, $col, $row) = @_;
  153.     return undef unless ref($self);
  154.  
  155.     return _WriteConsoleOutputCharacter($self->{'handle'},$text,$col,$row);
  156. }
  157.  
  158. #=============
  159. sub ReadChar {
  160. #=============
  161.     my($self, $size, $col, $row) = @_;
  162.     return undef unless ref($self);
  163.   
  164.     my $buffer = (" " x $size);  
  165.     if(_ReadConsoleOutputCharacter($self->{'handle'}, $buffer, $size, $col, $row)) {
  166.         return $buffer;
  167.     } else {
  168.         return undef;
  169.     }
  170. }
  171.  
  172.  
  173.  
  174. #==============
  175. sub WriteAttr {
  176. #==============
  177.     my($self, $attr, $col, $row) = @_;
  178.     return undef unless ref($self);
  179.     return _WriteConsoleOutputAttribute($self->{'handle'}, $attr, $col, $row);
  180. }
  181.  
  182. #=============
  183. sub ReadAttr {
  184. #=============
  185.     my($self, $size, $col, $row) = @_;
  186.     return undef unless ref($self);
  187.   
  188.     return _ReadConsoleOutputAttribute($self->{'handle'}, $size, $col, $row);
  189. }
  190.  
  191.  
  192. #==========
  193. sub Write {
  194. #==========
  195.     my($self,$string) = @_;
  196.     return undef unless ref($self);
  197.     return _WriteConsole($self->{'handle'}, $string);
  198. }
  199.  
  200.  
  201. #=============
  202. sub ReadRect {
  203. #=============
  204.     my($self, $left, $top, $right, $bottom) = @_;
  205.     return undef unless ref($self);
  206.     
  207.     my $col = $right  - $left + 1;
  208.     my $row = $bottom - $top  + 1;
  209.  
  210.     my $buffer = (" " x ($col*$row*4));
  211.     if(_ReadConsoleOutput($self->{'handle'},   $buffer,
  212.                           $col,  $row, 0,      0,
  213.                           $left, $top, $right, $bottom)) {
  214.         return $buffer;
  215.     } else {
  216.         return undef;
  217.     }
  218. }
  219.  
  220.  
  221. #==============
  222. sub WriteRect {
  223. #==============
  224.     my($self, $buffer, $left, $top, $right, $bottom) = @_;
  225.     return undef unless ref($self);
  226.  
  227.     my $col = $right  - $left + 1;
  228.     my $row = $bottom - $top  + 1;
  229.  
  230.     return _WriteConsoleOutput($self->{'handle'},   $buffer,
  231.                                $col,  $row, 0,  0,
  232.                                $left, $top, $right, $bottom);
  233. }
  234.  
  235.  
  236.  
  237. #===========
  238. sub Scroll {
  239. #===========
  240.     my($self, $left1, $top1, $right1, $bottom1,
  241.               $col,   $row,  $char,   $attr,
  242.               $left2, $top2, $right2, $bottom2) = @_;
  243.     return undef unless ref($self);
  244.   
  245.     return _ScrollConsoleScreenBuffer($self->{'handle'},
  246.                                       $left1, $top1, $right1, $bottom1,
  247.                                       $col,   $row,  $char,   $attr,
  248.                                       $left2, $top2, $right2, $bottom2);
  249. }
  250.  
  251.  
  252. #==============
  253. sub MaxWindow {
  254. #==============
  255.     my($self, $flag) = @_;
  256.     return undef unless ref($self);
  257.   
  258.     if(not defined($flag)) {
  259.         my @info = _GetConsoleScreenBufferInfo($self->{'handle'});
  260.         return $info[9], $info[10];
  261.     } else {
  262.         return _GetLargestConsoleWindowSize($self->{'handle'});
  263.     }
  264. }
  265.  
  266. #=========
  267. sub Info {
  268. #=========
  269.     my($self) = @_;
  270.     return undef unless ref($self);
  271.   
  272.     return _GetConsoleScreenBufferInfo($self->{'handle'});
  273. }
  274.  
  275.  
  276. #===========
  277. sub Window {
  278. #===========
  279.     my($self, $flag, $left, $top, $right, $bottom) = @_;
  280.     return undef unless ref($self);
  281.   
  282.     if(not defined($flag)) {
  283.         my @info = _GetConsoleScreenBufferInfo($self->{'handle'});
  284.         return $info[5], $info[6], $info[7], $info[8];
  285.     } else {
  286.         return _SetConsoleWindowInfo($self->{'handle'}, $flag, $left, $top, $right, $bottom);
  287.     }
  288. }
  289.  
  290. #==============
  291. sub GetEvents {
  292. #==============
  293.     my $self="";
  294.     ($self)=@_;
  295.     return undef unless ref($self);
  296.   
  297.     return _GetNumberOfConsoleInputEvents($self->{'handle'});
  298. }
  299.  
  300.  
  301. #==========
  302. sub Flush {
  303. #==========
  304.     my($self) = @_;
  305.     return undef unless ref($self);
  306.  
  307.     return _FlushConsoleInputBuffer($self->{'handle'});
  308. }
  309.  
  310. #==============
  311. sub InputChar {
  312. #==============
  313.     my($self, $number) = @_;
  314.     return undef unless ref($self);
  315.     
  316.     $number = 1 unless defined($number);
  317.   
  318.     my $buffer = (" " x $number);
  319.     if(_ReadConsole($self->{'handle'}, $buffer, $number) == $number) {
  320.         return $buffer;
  321.     } else {
  322.         return undef;
  323.     }
  324. }
  325.  
  326. #==========
  327. sub Input {
  328. #==========
  329.     my($self) = @_;
  330.     return undef unless ref($self);
  331.   
  332.     return _ReadConsoleInput($self->{'handle'});
  333. }
  334.  
  335. #==============
  336. sub PeekInput {
  337. #==============
  338.     my($self) = @_;
  339.     return undef unless ref($self);
  340.   
  341.     return _PeekConsoleInput($self->{'handle'});
  342. }
  343.  
  344.  
  345. #===============
  346. sub WriteInput {
  347. #===============
  348.     my($self) = shift;
  349.     return undef unless ref($self);
  350.   
  351.     return _WriteConsoleInput($self->{'handle'}, @_);
  352. }
  353.  
  354.  
  355. #=========
  356. sub Mode {
  357. #=========
  358.     my($self, $mode) = @_;
  359.     return undef unless ref($self);
  360.   
  361.     if(defined($mode)) {
  362.         return _SetConsoleMode($self->{'handle'}, $mode);
  363.     } else {
  364.         return _GetConsoleMode($self->{'handle'});
  365.     }
  366. }
  367.  
  368. #========
  369. sub Cls {
  370. #========
  371.     my($self, $attr) = @_;
  372.     return undef unless ref($self);
  373.  
  374.     $attr = $main::ATTR_NORMAL unless defined($attr);
  375.     
  376.     my ($x, $y) = $self->Size();
  377.     my($left, $top, $right ,$bottom) = $self->Window();
  378.     my $vx = $right  - $left;
  379.     my $vy = $bottom - $top;
  380.     $self->FillChar(" ", $x*$y, 0, 0);
  381.     $self->FillAttr($attr, $x*$y, 0, 0);
  382.     $self->Cursor(0, 0);
  383.     $self->Window(1, 0, 0, $vx, $vy);
  384. }
  385.  
  386.  
  387. #=========
  388. sub Attr {
  389. #=========
  390.     my($self, $attr) = @_;
  391.     return undef unless ref($self);
  392.   
  393.     if(not defined($attr)) {
  394.         return (_GetConsoleScreenBufferInfo($self->{'handle'}))[4];
  395.     } else {
  396.         return _SetConsoleTextAttribute($self->{'handle'}, $attr);
  397.     }
  398. }
  399.  
  400. #===========
  401. sub Cursor {
  402. #===========
  403.     my($self, $col, $row, $size, $visi) = @_;
  404.     return undef unless ref($self);
  405.  
  406.     my $curr_row  = 0;
  407.     my $curr_col  = 0;
  408.     my $curr_size = 0;
  409.     my $curr_visi = 0;
  410.     my $return    = 0;
  411.     my $discard   = 0;
  412.  
  413.   
  414.     if(defined($col)) {
  415.         $row = -1 if not defined($row);
  416.         if($col == -1 or $row == -1) {
  417.             ($discard, $discard, $curr_col, $curr_row) = _GetConsoleScreenBufferInfo($self->{'handle'});
  418.             $col=$curr_col if $col==-1;
  419.             $row=$curr_row if $row==-1;
  420.         }
  421.         $return += _SetConsoleCursorPosition($self->{'handle'}, $col, $row);
  422.         if(defined($size) and defined($visi)) {
  423.             if($size == -1 or $visi == -1) {
  424.                 ($curr_size, $curr_visi) = _GetConsoleCursorInfo($self->{'handle'});
  425.                 $size = $curr_size if $size == -1;
  426.                 $visi = $curr_visi if $visi == -1;
  427.             }
  428.             $size = 1 if $size < 1;
  429.             $size = 99 if $size > 99;
  430.             $return += _SetConsoleCursorInfo($self->{'handle'}, $size, $visi);
  431.         }
  432.         return $return;
  433.     } else {
  434.         ($discard, $discard, $curr_col, $curr_row) = _GetConsoleScreenBufferInfo($self->{'handle'});
  435.         ($curr_size, $curr_visi) = _GetConsoleCursorInfo($self->{'handle'});
  436.         return ($curr_col, $curr_row, $curr_size, $curr_visi);
  437.     }
  438. }
  439.   
  440. #=========
  441. sub Size {
  442. #=========
  443.     my($self, $col, $row) = @_;
  444.     return undef unless ref($self);
  445.     if(not defined($col)) {
  446.         ($col, $row) = _GetConsoleScreenBufferInfo($self->{'handle'});
  447.         return ($col, $row);
  448.     } else {
  449.         $row = -1 if not defined($row);
  450.         if($col == -1 or $row == -1) {
  451.             ($curr_col, $curr_row) = _GetConsoleScreenBufferInfo($self->{'handle'});
  452.             $col=$curr_col if $col==-1;
  453.             $row=$curr_row if $row==-1;
  454.         }
  455.         return _SetConsoleScreenBufferSize($self->{'handle'}, $col, $row);
  456.     }
  457. }
  458.  
  459. #=============
  460. sub FillAttr {
  461. #=============
  462.     my($self, $attr, $number, $col, $row) = @_;
  463.     return undef unless ref($self);
  464.  
  465.     $number = 1 unless $number;
  466.  
  467.     if(!defined($col) or !defined($row) or $col == -1 or $row == -1) {
  468.         ($discard,  $discard, 
  469.          $curr_col, $curr_row) = _GetConsoleScreenBufferInfo($self->{'handle'});
  470.         $col = $curr_col if !defined($col) or $col == -1;
  471.         $row = $curr_row if !defined($row) or $row == -1;
  472.     }
  473.     return _FillConsoleOutputAttribute($self->{'handle'}, $attr, $number, $col, $row);
  474. }
  475.  
  476. #=============
  477. sub FillChar {
  478. #=============
  479.     my($self, $char, $number, $col, $row) = @_;
  480.     return undef unless ref($self);
  481.  
  482.     if(!defined($col) or !defined($row) or $col == -1 or $row == -1) {
  483.         ($discard,  $discard,
  484.          $curr_col, $curr_row) = _GetConsoleScreenBufferInfo($self->{'handle'});
  485.         $col = $curr_col if !defined($col) or $col == -1;
  486.         $row = $curr_row if !defined($row) or $row == -1;
  487.     }
  488.     return _FillConsoleOutputCharacter($self->{'handle'}, $char, $number, $col, $row);
  489. }
  490.  
  491. #============
  492. sub InputCP {
  493. #============
  494.     my($self, $codepage) = @_;
  495.     $codepage = $self if (defined($self) and ref($self) ne "Win32::Console");
  496.     if(defined($codepage)) {
  497.         return _SetConsoleCP($codepage);
  498.     } else {
  499.         return _GetConsoleCP();
  500.     }
  501. }
  502.  
  503. #=============
  504. sub OutputCP {
  505. #=============
  506.     my($self, $codepage) = @_;
  507.     $codepage = $self if (defined($self) and ref($self) ne "Win32::Console");
  508.     if(defined($codepage)) {
  509.         return _SetConsoleOutputCP($codepage);
  510.     } else {
  511.         return _GetConsoleOutputCP();
  512.     }
  513. }
  514.  
  515. #======================
  516. sub GenerateCtrlEvent {
  517. #======================
  518.     my($self, $type, $pid) = @_;
  519.     $type = constant("CTRL_C_EVENT", 0) unless defined($type);
  520.     $pid = 0 unless defined($pid);
  521.     return _GenerateCtrlEvent($type, $pid);
  522. }
  523.  
  524. #===================
  525. #sub SetCtrlHandler {
  526. #===================
  527. #    my($name, $add) = @_;
  528. #    $add = 1 unless defined($add);
  529. #    my @nor = keys(%HandlerRoutineStack);
  530. #    if($add == 0) {
  531. #        foreach $key (@nor) {
  532. #            delete $HandlerRoutineStack{$key}, last if $HandlerRoutineStack{$key}==$name;
  533. #        }
  534. #        $HandlerRoutineRegistered--;
  535. #    } else {
  536. #        if($#nor == -1) {
  537. #            my $r = _SetConsoleCtrlHandler();
  538. #            if(!$r) {
  539. #                print "WARNING: SetConsoleCtrlHandler failed...\n";
  540. #            }
  541. #        }
  542. #        $HandlerRoutineRegistered++;
  543. #        $HandlerRoutineStack{$HandlerRoutineRegistered} = $name;
  544. #    }
  545. #}
  546.  
  547.  
  548. ########################################################################
  549. # PRIVATE METHODS
  550. #
  551.  
  552. #================
  553. #sub CtrlHandler {
  554. #================
  555. #    my($ctrltype) = @_;
  556. #    my $routine;
  557. #    my $result = 0;
  558. #    CALLEM: foreach $routine (sort { $b <=> $a } keys %HandlerRoutineStack) {
  559. #        #print "CtrlHandler: calling $HandlerRoutineStack{$routine}($ctrltype)\n";
  560. #        $result = &{"main::".$HandlerRoutineStack{$routine}}($ctrltype);
  561. #        last CALLEM if $result;
  562. #    }
  563. #    return $result;
  564. #}
  565.  
  566. #============  (MAIN DESTRUCTOR)
  567. sub DESTROY {
  568. #============
  569.     my($self) = @_;
  570.     _CloseHandle($self->{'handle'});
  571. }
  572.  
  573.  
  574.  
  575. #######################################################################
  576. # dynamically load in the Console.pll module.
  577. #
  578.  
  579. bootstrap Win32::Console;
  580.  
  581. #######################################################################
  582. # ADDITIONAL CONSTANTS EXPORTED IN THE MAIN NAMESPACE
  583. #
  584.  
  585. $main::FG_BLACK        = 0;
  586. $main::FG_BLUE         = constant("FOREGROUND_BLUE",0);
  587. $main::FG_LIGHTBLUE    = constant("FOREGROUND_BLUE",0)|
  588.                          constant("FOREGROUND_INTENSITY",0);
  589. $main::FG_RED          = constant("FOREGROUND_RED",0);
  590. $main::FG_LIGHTRED     = constant("FOREGROUND_RED",0)|
  591.                          constant("FOREGROUND_INTENSITY",0);
  592. $main::FG_GREEN        = constant("FOREGROUND_GREEN",0);
  593. $main::FG_LIGHTGREEN   = constant("FOREGROUND_GREEN",0)|
  594.                          constant("FOREGROUND_INTENSITY",0);
  595. $main::FG_MAGENTA      = constant("FOREGROUND_RED",0)|
  596.                          constant("FOREGROUND_BLUE",0);
  597. $main::FG_LIGHTMAGENTA = constant("FOREGROUND_RED",0)|
  598.                          constant("FOREGROUND_BLUE",0)|
  599.                          constant("FOREGROUND_INTENSITY",0);
  600. $main::FG_CYAN         = constant("FOREGROUND_GREEN",0)|
  601.                          constant("FOREGROUND_BLUE",0);
  602. $main::FG_LIGHTCYAN    = constant("FOREGROUND_GREEN",0)|
  603.                          constant("FOREGROUND_BLUE",0)|
  604.                          constant("FOREGROUND_INTENSITY",0);
  605. $main::FG_BROWN        = constant("FOREGROUND_RED",0)|
  606.                          constant("FOREGROUND_GREEN",0);
  607. $main::FG_YELLOW       = constant("FOREGROUND_RED",0)|
  608.                          constant("FOREGROUND_GREEN",0)|
  609.                          constant("FOREGROUND_INTENSITY",0);
  610. $main::FG_GRAY         = constant("FOREGROUND_RED",0)|
  611.                          constant("FOREGROUND_GREEN",0)|
  612.                          constant("FOREGROUND_BLUE",0);
  613. $main::FG_WHITE        = constant("FOREGROUND_RED",0)|
  614.                          constant("FOREGROUND_GREEN",0)|
  615.                          constant("FOREGROUND_BLUE",0)|
  616.                          constant("FOREGROUND_INTENSITY",0);
  617.  
  618. $main::BG_BLACK        = 0;
  619. $main::BG_BLUE         = constant("BACKGROUND_BLUE",0);
  620. $main::BG_LIGHTBLUE    = constant("BACKGROUND_BLUE",0)|
  621.                          constant("BACKGROUND_INTENSITY",0);
  622. $main::BG_RED          = constant("BACKGROUND_RED",0);
  623. $main::BG_LIGHTRED     = constant("BACKGROUND_RED",0)|
  624.                          constant("BACKGROUND_INTENSITY",0);
  625. $main::BG_GREEN        = constant("BACKGROUND_GREEN",0);
  626. $main::BG_LIGHTGREEN   = constant("BACKGROUND_GREEN",0)|
  627.                          constant("BACKGROUND_INTENSITY",0);
  628. $main::BG_MAGENTA      = constant("BACKGROUND_RED",0)|
  629.                          constant("BACKGROUND_BLUE",0);
  630. $main::BG_LIGHTMAGENTA = constant("BACKGROUND_RED",0)|
  631.                          constant("BACKGROUND_BLUE",0)|
  632.                          constant("BACKGROUND_INTENSITY",0);
  633. $main::BG_CYAN         = constant("BACKGROUND_GREEN",0)|
  634.                          constant("BACKGROUND_BLUE",0);
  635. $main::BG_LIGHTCYAN    = constant("BACKGROUND_GREEN",0)|
  636.                          constant("BACKGROUND_BLUE",0)|
  637.                          constant("BACKGROUND_INTENSITY",0);
  638. $main::BG_BROWN        = constant("BACKGROUND_RED",0)|
  639.                          constant("BACKGROUND_GREEN",0);
  640. $main::BG_YELLOW       = constant("BACKGROUND_RED",0)|
  641.                          constant("BACKGROUND_GREEN",0)|
  642.                          constant("BACKGROUND_INTENSITY",0);
  643. $main::BG_GRAY         = constant("BACKGROUND_RED",0)|
  644.                          constant("BACKGROUND_GREEN",0)|
  645.                          constant("BACKGROUND_BLUE",0);
  646. $main::BG_WHITE        = constant("BACKGROUND_RED",0)|
  647.                          constant("BACKGROUND_GREEN",0)|
  648.                          constant("BACKGROUND_BLUE",0)|
  649.                          constant("BACKGROUND_INTENSITY",0);
  650.  
  651. $main::ATTR_NORMAL = $main::FG_GRAY|$main::BG_BLACK;
  652. $main::ATTR_INVERSE = $main::FG_BLACK|$main::BG_GRAY;
  653.  
  654. undef unless $main::ATTR_NORMAL;
  655. undef unless $main::ATTR_INVERSE;
  656. undef unless $VERSION;
  657.  
  658. @main::CONSOLE_COLORS = ();
  659.  
  660. foreach $fg ($main::FG_BLACK, $main::FG_BLUE, $main::FG_GREEN, $main::FG_CYAN, 
  661.              $main::FG_RED, $main::FG_MAGENTA, $main::FG_BROWN, $main::FG_GRAY,
  662.              $main::FG_LIGHTBLUE, $main::FG_LIGHTGREEN, $main::FG_LIGHTCYAN,
  663.              $main::FG_LIGHTRED, $main::FG_LIGHTMAGENTA, $main::FG_YELLOW, 
  664.              $main::FG_WHITE) {
  665.  
  666.     foreach $bg ($main::BG_BLACK, $main::BG_BLUE, $main::BG_GREEN, $main::BG_CYAN, 
  667.                  $main::BG_RED, $main::BG_MAGENTA, $main::BG_BROWN, $main::BG_GRAY,
  668.                  $main::BG_LIGHTBLUE, $main::BG_LIGHTGREEN, $main::BG_LIGHTCYAN,
  669.                  $main::BG_LIGHTRED, $main::BG_LIGHTMAGENTA, $main::BG_YELLOW, 
  670.                  $main::BG_WHITE) {
  671.         push(@main::CONSOLE_COLORS, $fg|$bg);
  672.     }
  673. }
  674.  
  675. undef $fg;
  676. undef $bg;
  677.  
  678. # Preloaded methods go here.
  679.  
  680. #Currently Autoloading is not implemented in Perl for win32
  681. # Autoload methods go after __END__, and are processed by the autosplit program.
  682.  
  683. 1;
  684.  
  685. __END__
  686.  
  687.